<template>
   <div id="tableApprovalBody">
        <!--分页组件-->
        <el-table style="width: 100%" stripe border @selection-change="handleSelectionChange" highlight-current-row
            :data="dataList">
            <!-- 复选框 -->
            <el-table-column type="selection" width="40"></el-table-column>
            <el-table-column label="序号" min-width="50">
                <template slot-scope="scope">
                    {{ scope.$index + 1 }}
                </template>
            </el-table-column>
            <el-table-column align="left" prop="behavior" :formatter="formatBehavior" show-overflow-tooltip
                label="审批状态"></el-table-column>
            <el-table-column align="left" prop="comment" show-overflow-tooltip label="审批内容"></el-table-column>
            <el-table-column align="left" prop="createTime" show-overflow-tooltip label="审批时间"></el-table-column>
            <el-table-column align="center" prop="createBy" label="审批人" min-width="150"></el-table-column>
        </el-table>
        <div class="block">
            <el-pagination hide-on-single-page @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="pageNo" :page-sizes="[5, 10, 30, 50]" :page-size="pageSize"
                layout="->,total, sizes, prev, pager, next, jumper" :total="totalCount">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify, handleAlert, handleConfirm, showWating, closeWating, dateformat } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            searchForm: { instanceId: "" },
            dataList: [],
            sels: [], //当前选框选中的值
            pageNo: 1,      // 默认当前是第一页
            pageSize: 5,    // 当前每页的数据是5条
            totalCount: 0,   // 总数默认为0
        }
    },
    components: {

    },
    props: {
        instanceId:null,
    },
    watch: {
    },
    mounted() {
        this.initApply();
    },
    methods: {
        initApply() {
            this.restForm();
            this.searchForm.instanceId = this.instanceId;
            this.initList();
        },
        restForm() {
            //重置
            Object.assign(this.$data.searchForm, this.$options.data().searchForm);
        },
        initList() {
            showWating({ renderBody: "tableApprovalBody" });
            var params = {};
            params.usePageNo = true;//采用第几页进行分页（兼容）
            params.pageSize = this.pageSize;//页面显示记录条数，在页面显示每页显示多少项的时候
            params.pageNo = this.pageNo;//开始的记录序号   
            params.searchJson = JSON.stringify(this.searchForm);//为form元素     
            apiUtil.queryPage(process.env.VUE_APP_BPM_API + "/lcApproval/list", params).then(({ data }) => {
                this.dataList = data.data;//给结果集赋值
                this.totalCount = data.total;// 获取当前数据的总数    
            });
        },
        handleSelectionChange(sels) {//获取选中的值
            this.sels = sels;
        },
        handleSizeChange(val) { // 修改每页所存数据量的值所触发的函数
            this.pageSize = val;  // 修改页的大小
            this.initList();       // 按新的pageNo和pageSize进行查询
        },
        handleCurrentChange(val) { // 修改当前页所触发的函数
            this.pageNo = val;       // 更新当前的页
            this.initList();          // 按新的pageNo和pageSize进行查询
        },
        search() {
            this.pageNo = 1;       // 更新当前的页
            this.initList();          // 按新的pageNo和pageSize进行查询
        },
        resetAll() {
            Object.assign(this.$data.searchForm, this.$options.data().searchForm);
            this.search();
        },
        formatBehavior(row) {
            let data = row.behavior;
            if (data == 0) {
                return "提交";
            }
            if (data == 10) {
                return "通过";
            }
            if (data == 20) {
                return "驳回";
            }
            if (data == 30) {
                return "弃权";
            }
            if (data == 40) {
                return "撤回";
            }
            if (data == 50) {
                return "终止流程";
            }
            if (data == 60) {
                return "执行跳转";
            }
            if (data == 70) {
                return "转办";
            }
            if (data == 80) {
                return "委派";
            }
            if (data == 90) {
                return "加签";
            }
            if (data == 100) {
                return "催办";
            }
            if (data == 110) {
                return "设置归属人";
            }
            if (data == 120) {
                return "挂起";
            }
            if (data == 130) {
                return "激活";
            }
            return "缺省";
        }
    }
}
</script>